package com.bw.app.func;

import org.apache.flink.table.annotation.DataTypeHint;
import org.apache.flink.table.annotation.FunctionHint;
import org.apache.flink.table.functions.TableFunction;
import org.apache.flink.types.Row;
import org.wltea.analyzer.core.IKSegmenter;
import org.wltea.analyzer.core.Lexeme;

import java.io.IOException;
import java.io.StringReader;

//a,b,c,d    a,1    b,1   c,  d
@FunctionHint(output = @DataTypeHint("ROW<word STRING>"))
public class LaterViewFuntion   extends TableFunction<Row> {

    //辉煌八维大数据
    public void eval(String  str) throws IOException {

        StringReader reader = new StringReader(str);
        //1.创建IK
        IKSegmenter ikSegmenter = new IKSegmenter(reader, true);
        //2.通过流获取迭代器
        Lexeme next = ikSegmenter.next();
        //3.循环变量
        while (next !=null){
            collect(Row.of(next.getLexemeText()));
            next=ikSegmenter.next();
        }



    }

}
